#include <fasys/messages_container.hpp>

struct f_get
{
  template<typename T>
  void operator()(const T& t)
  {
    std::cout << t.message_id << " " << (t.data!=0) << std::endl;
  }
};

int main()
{
  fasys::data_t data;
  data.push_back(10);
  fasys::messages_container mcc;
  fasys::message_info mi;
  mi.create(1, 1, 60, 0, 2);
  mi.attach(new fasys::data_t(data) );
  
  size_t count = mcc.insert(mi);
  if (count!=1) return 1;

  mi = fasys::message_info();
  mi.create(1, 2, 60, 0, 2);
  mi.attach(new fasys::data_t(data) );
  count = mcc.insert(mi);
  if (count!=2) return 1;

  mi = fasys::message_info();
  mi.create(1, 3, 60, 0, 2);
  mi.attach(new fasys::data_t(data) );
  count = mcc.insert(mi);
  if (count!=2) return 1;
  mcc.select_by_order(f_get(), 1, 0, 1000);
  mcc.detach_by_order(f_get(), 1, 0, 1000);
  return 0;
}